/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JpnlFinalParams.java
 *
 * Created on 08/06/2010, 16:59:12
 */
package systole.view.tabs.finalsegment;

import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
import java.math.BigDecimal;
import java.math.BigInteger;

import java.text.DecimalFormat;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumnModel;
import org.jdesktop.application.Action;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.event.ChartProgressEvent;
import org.jfree.chart.event.ChartProgressListener;
import org.jfree.chart.plot.Marker;
import org.jfree.chart.plot.ValueMarker;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import systole.domain.analysis.results.Parameter;
import systole.domain.analysis.results.ParameterCoord;
import systole.domain.analysis.results.ParametersKind;
import systole.view.charts.XYChart;
import systole.view.charts.XYParameterList;
import systole.view.tabs.controllers.AnalysisController;
import systole.view.tabs.controllers.ResultsModel;
import systole.view.utils.ColumnGroup;
import systole.view.utils.GroupableTableHeader;

/**
 *
 * @author user
 */
public class JpnlFinalParams extends javax.swing.JPanel implements ListSelectionListener, ChangeListener, ChartProgressListener {

    /**
     *
     */
    private static final long serialVersionUID = -9058866960707739087L;
    private boolean derivativesVisible = false;
    private boolean yAxisEnabled = false;
    private Marker marker = null;
    private XYChart paramsChart;
    private ChartPanel paramsChartPanel;
    private SignalParamsModel paramsModel;
    private AnalysisController analysisController;
    private XYParameterList chartParameters;
    private ParameterCoord currentPoint = new ParameterCoord(BigDecimal.ZERO, BigDecimal.ZERO);
    private final DecimalFormat format = new DecimalFormat("###0.00");
    private static final BigDecimal fifty = new BigDecimal(50);

    /** Creates new form JpnlFinalParams 
     * @param analysisController
     */
    public JpnlFinalParams(AnalysisController analysisController) {
        initComponents();
        this.analysisController = analysisController;
        jTableParams = new javax.swing.JTable() {

            @Override
            protected JTableHeader createDefaultTableHeader() {
                return new GroupableTableHeader(columnModel);
            }
        };
        jTableParams.setName("jTableParams"); // NOI18N
        jTableParams.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        this.paramsModel = new SignalParamsModel(this.analysisController.getResultsModel(), this.jTableParams);
        this.jTableParams.setModel(paramsModel);
        this.analysisController.getResultsModel().addObserver(this.paramsModel);
        TableColumnModel cm = this.jTableParams.getColumnModel();
        cm.getColumn(0).setMinWidth(200);
        cm.getColumn(0).setMaxWidth(200);
        cm.getColumn(0).setPreferredWidth(200);

        ColumnGroup g_startPoint = new ColumnGroup("Punto Inicial - (P1)");
        g_startPoint.add(cm.getColumn(1));
        g_startPoint.add(cm.getColumn(2));
        ColumnGroup g_endPoint = new ColumnGroup("Punto Final - (P2)");
        g_endPoint.add(cm.getColumn(3));
        g_endPoint.add(cm.getColumn(4));

        GroupableTableHeader header = (GroupableTableHeader) this.jTableParams.getTableHeader();
        header.addColumnGroup(g_startPoint);
        header.addColumnGroup(g_endPoint);

        this.jTableParams.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        this.jTableParams.getSelectionModel().addListSelectionListener(this);
        jScrollParams.setViewportView(this.jTableParams);
    }

    public void loadSegments() {

        ResultsModel model = this.analysisController.getResultsModel();

        double xScaleFactor = this.analysisController.getAnalysis().getSignalFrequency().getFrequency().doubleValue();
        this.paramsChart = new XYChart("Parámetros Segmento Final", "Tiempo (ms)", "Amplitud (%)");
        this.paramsChart.addSeries("Latido", model.getCurrentFinalSignal().getFinalSegment().toDoubleArray(), xScaleFactor);
        this.paramsChart.addSeries("Derivada 2da", model.getCurrentFinalSignal().getSecondDerivative().toDoubleArray(), xScaleFactor);
        this.paramsChart.addSeries("Derivada 4ta", model.getCurrentFinalSignal().getFourthDerivative().toDoubleArray(), xScaleFactor);
        this.paramsChartPanel = this.paramsChart.plot();
        this.paramsChartPanel.getChart().getXYPlot().setDomainCrosshairVisible(true);
        this.paramsChartPanel.getChart().getXYPlot().setRangeCrosshairVisible(true);
        this.paramsChartPanel.getChart().addProgressListener(this);

        XYItemRenderer rend = this.paramsChartPanel.getChart().getXYPlot().getRenderer();
        rend.setSeriesVisible(1, false, true);
        rend.setSeriesVisible(2, false, true);

        this.chartParameters = new XYParameterList(this.paramsChartPanel.getChart().getXYPlot(), this.analysisController.getResultsModel());

        int minValue = 0;
        int maxValue = model.getCurrentFinalSignal().getFinalSegment().size() - 1;

        this.jXYSlider.setMinimum(minValue);
        this.jXYSlider.setMaximum(maxValue);
        this.jXYSlider.setValue((int) Math.floor(maxValue / 2));
        this.jXYSlider.addChangeListener(this);

        this.txtTraceXCoord.setText("0");
        this.txtTraceYCoord.setText("0");
        this.jLblCurrentParam.setText(" ");

        this.jPnlParamChart.removeAll();
        this.jPnlParamChart.setLayout(new BorderLayout());
        this.jPnlParamChart.add(this.paramsChartPanel, BorderLayout.CENTER);
    }

    @Action
    public void toggleDerivatives() {
        String caption = "<html><center>";
        caption += (this.derivativesVisible) ? "Mostrar" : "Ocultar";
        caption += "<br>Derivadas</center></html>";

        this.derivativesVisible = !this.derivativesVisible;

        XYItemRenderer rend = this.paramsChartPanel.getChart().getXYPlot().getRenderer();
        rend.setSeriesVisible(1, this.derivativesVisible, true);
        rend.setSeriesVisible(2, this.derivativesVisible, true);

        this.btnToggleDerivatives.setText(caption);
    }

    @Action
    public void toggleConstantValue() {

        String caption = "<html><center>";
        caption += (this.yAxisEnabled) ? "Mostrar" : "Ocultar";
        caption += "<br/>Corte 50%</center></html>";

        this.yAxisEnabled = !this.yAxisEnabled;

        if (this.yAxisEnabled) {
            this.marker = new ValueMarker(50);
            this.marker.setPaint(Color.DARK_GRAY);
            this.marker.setStroke(new BasicStroke(1.0f));
            this.paramsChartPanel.getChart().getXYPlot().addRangeMarker(marker);
        } else {
            if (this.marker != null) {
                this.paramsChartPanel.getChart().getXYPlot().removeRangeMarker(marker);
            }
        }

        this.btnConstantFifty.setText(caption);
    }

    public void valueChanged(ListSelectionEvent e) {
        ListSelectionModel lsm = (ListSelectionModel) e.getSource();

        if (lsm.isSelectionEmpty()) {
            this.chartParameters.removeParameters();
        } else {
            int selectedRow = lsm.getMaxSelectionIndex();

            Parameter p = this.paramsModel.getParameter(selectedRow);

            this.jLblCurrentParam.setText(p.getDescription());

            this.txtXStartPoint.setText(p.getInitPos().getXasString());
            this.txtYStartPoint.setText(p.getInitPos().getYasString());

            this.txtXEndPoint.setText(p.getEndPos().getXasString());
            this.txtYEndPoint.setText(p.getEndPos().getYasString());
            this.txtParamValue.setText(p.getValueAsString());

            this.chartParameters.showParameter(selectedRow);
        }
    }

    /**
     * Handles a state change event.
     *
     * @param event  the event.
     */
    public void stateChanged(ChangeEvent event) {

        this.currentPoint.setxCoord(this.analysisController.getAnalysis().getSignalFrequency().getFrequency().multiply(new BigDecimal(this.jXYSlider.getValue())));
        this.currentPoint.setyCoord(this.analysisController.getResultsModel().getCurrentFinalSignal().getFinalSegment().elementAt(this.jXYSlider.getValue()));

        this.paramsChartPanel.getChart().getXYPlot().setDomainCrosshairValue(this.currentPoint.getxCoord().doubleValue());
        this.paramsChartPanel.getChart().getXYPlot().setRangeCrosshairValue(this.currentPoint.getyCoord().doubleValue());

        this.txtTraceXCoord.setText(this.format.format(this.currentPoint.getxCoord()));
        this.txtTraceYCoord.setText(this.format.format(this.currentPoint.getyCoord()));

        if (this.chkStartUseCurPoint.isSelected()) {
            this.txtXStartPoint.setText(this.format.format(this.currentPoint.getxCoord()));
            this.txtYStartPoint.setText(this.format.format(this.currentPoint.getyCoord()));
            this.RTParamCalc();
        }

        if (this.chkEndUseCurPoint.isSelected()) {
            this.txtXEndPoint.setText(this.format.format(this.currentPoint.getxCoord()));
            this.txtYEndPoint.setText(this.format.format(this.currentPoint.getyCoord()));
            this.RTParamCalc();
        }
    }

    /**
     * Handles a chart progress event.
     *
     * @param event  the event.
     */
    public void chartProgress(ChartProgressEvent event) {

        if (event.getType() != ChartProgressEvent.DRAWING_FINISHED) {
            return;
        }

        this.txtTraceXCoord.setText(this.format.format(event.getChart().getXYPlot().getDomainCrosshairValue()));
        this.txtTraceYCoord.setText(this.format.format(event.getChart().getXYPlot().getRangeCrosshairValue()));
        int x = (int) (event.getChart().getXYPlot().getDomainCrosshairValue() / this.analysisController.getAnalysis().getSignalFrequency().getFrequency().floatValue());
        this.jXYSlider.setValue(x);
    }

    @Action
    public void traceCurrentStartPoint() {

        int curRow = this.jTableParams.getSelectedRow();
        if (curRow == -1) {
            return;
        }

        Parameter p = this.paramsModel.getParameter(curRow);

        if (this.chkStartUseCurPoint.isSelected()) {

            this.chkEndUseCurPoint.setSelected(false);
            this.txtXStartPoint.setText(this.txtTraceXCoord.getText());
            this.txtYStartPoint.setText(this.txtTraceYCoord.getText());

            this.txtXEndPoint.setText(p.getEndPos().getXasString());
            this.txtYEndPoint.setText(p.getEndPos().getYasString());
            this.RTParamCalc();

        } else {

            this.txtXStartPoint.setText(p.getInitPos().getXasString());
            this.txtYStartPoint.setText(p.getInitPos().getYasString());
            this.txtParamValue.setText(p.getValueAsString());
        }
    }

    @Action
    public void traceCurrentEndPoint() {

        int curRow = this.jTableParams.getSelectedRow();
        if (curRow == -1) {
            return;
        }

        Parameter p = this.paramsModel.getParameter(curRow);

        if (this.chkEndUseCurPoint.isSelected()) {

            this.chkStartUseCurPoint.setSelected(false);
            this.txtXEndPoint.setText(this.txtTraceXCoord.getText());
            this.txtYEndPoint.setText(this.txtTraceYCoord.getText());
            this.txtXStartPoint.setText(p.getInitPos().getXasString());
            this.txtYStartPoint.setText(p.getInitPos().getYasString());
            this.RTParamCalc();

        } else {

            this.txtXEndPoint.setText(p.getEndPos().getXasString());
            this.txtYEndPoint.setText(p.getEndPos().getYasString());
            this.txtParamValue.setText(p.getValueAsString());
        }
    }

    @Action
    public void updateAnalysisParameter() {
        ParameterCoord newStart = new ParameterCoord(new BigDecimal(this.txtXStartPoint.getText().replace(",", ".")), new BigDecimal(this.txtYStartPoint.getText().replace(",", ".")));
        ParameterCoord newEnd = new ParameterCoord(new BigDecimal(this.txtXEndPoint.getText().replace(",", ".")), new BigDecimal(this.txtYEndPoint.getText().replace(",", ".")));

        int modelRow = this.jTableParams.getSelectedRow();
        if (modelRow == -1) {
            return; //debiera de seleccionar una fila
        }
        switch (modelRow) {
            case SignalParamsModel.AOD_INDEX:
                this.analysisController.getResultsModel().updateAOD(newStart, newEnd);
                break;
            case SignalParamsModel.AOS_INDEX:
                // siempre es sobre la linea el 50%
                newStart.setyCoord(fifty);
                newEnd.setyCoord(fifty);
                this.analysisController.getResultsModel().updateAOS(newStart, newEnd);
                break;
            case SignalParamsModel.T_INDEX:
                this.analysisController.getResultsModel().updateT(newStart, newEnd);
                break;
            case SignalParamsModel.IAR_INDEX:
                // siempre p1.y=0 y p1.x=p2.x
                if (this.chkEndUseCurPoint.isSelected()) {
                    newStart.setxCoord(newEnd.getxCoord());
                }
                if (this.chkStartUseCurPoint.isSelected()) {
                    newEnd.setxCoord(newStart.getxCoord());
                    newEnd.setyCoord(newStart.getyCoord());
                    newStart.setyCoord(BigDecimal.ZERO);
                }
                this.analysisController.getResultsModel().updateIAR(newStart, newEnd);
                break;
        }
        this.jTableParams.setRowSelectionInterval(modelRow, modelRow);
        this.enableTraceChecks();
    }

    @Action
    public void restoreOriginalParameters() {
        int modelRow = this.jTableParams.getSelectedRow();
        if (modelRow == -1) {
            return; //debiera de seleccionar una fila
        }

        switch (modelRow) {
            case SignalParamsModel.AOD_INDEX:
                this.analysisController.getResultsModel().restoreAOD();
                break;
            case SignalParamsModel.AOS_INDEX:
                this.analysisController.getResultsModel().restoreAOS();
                break;
            case SignalParamsModel.T_INDEX:
                this.analysisController.getResultsModel().restoreT();
                break;
            case SignalParamsModel.IAR_INDEX:
                this.analysisController.getResultsModel().restoreIAR();
                break;
        }
        this.jTableParams.setRowSelectionInterval(modelRow, modelRow);
        this.enableTraceChecks();
    }

    private void enableTraceChecks() {
        this.chkStartUseCurPoint.setEnabled(true);
        this.chkEndUseCurPoint.setEnabled(true);
    }

    private void RTParamCalc() {

        double x1, x2, y1, y2;

        x1 = Double.valueOf(this.txtXStartPoint.getText().replace(",", "."));
        x2 = Double.valueOf(this.txtXEndPoint.getText().replace(",", "."));
        y1 = Double.valueOf(this.txtYStartPoint.getText().replace(",", "."));
        y2 = Double.valueOf(this.txtYEndPoint.getText().replace(",", "."));

        int row = this.jTableParams.getSelectedRow();
        if (row == -1) {
            return;
        }

        String desc = this.paramsModel.getParameter(row).getDescription();
        Float newValue = new Float(0.0f);

        if (desc.equals(ParametersKind.AOD) || desc.equals(ParametersKind.IAR)) {
            newValue = new Float(y2 - y1);
        } else {
            newValue = new Float(x2 - x1);
        }

        this.txtParamValue.setText(newValue.toString());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPnlChartTools = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        txtTraceYCoord = new javax.swing.JTextField();
        jLblYCoord = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLblXCoord = new javax.swing.JLabel();
        txtTraceXCoord = new javax.swing.JTextField();
        jPanel10 = new javax.swing.JPanel();
        btnToggleDerivatives = new javax.swing.JButton();
        btnConstantFifty = new javax.swing.JButton();
        jPnlPlot = new javax.swing.JPanel();
        jSliderPanel = new javax.swing.JPanel();
        jXYSlider = new javax.swing.JSlider();
        jPnlParamChart = new javax.swing.JPanel();
        jPnlResults = new javax.swing.JPanel();
        jPnlParams = new javax.swing.JPanel();
        jPnlEditParam = new javax.swing.JPanel();
        jPnlBtnsParams = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        txtParamValue = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        btnConfirm = new javax.swing.JButton();
        btnReset = new javax.swing.JButton();
        jPnlParamsPoints = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLblP1X = new javax.swing.JLabel();
        txtXStartPoint = new javax.swing.JTextField();
        jLblP1Y = new javax.swing.JLabel();
        txtYStartPoint = new javax.swing.JTextField();
        jPanel6 = new javax.swing.JPanel();
        chkStartUseCurPoint = new javax.swing.JCheckBox();
        jPanel1 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jLblp2X = new javax.swing.JLabel();
        txtXEndPoint = new javax.swing.JTextField();
        jLblP2Y = new javax.swing.JLabel();
        txtYEndPoint = new javax.swing.JTextField();
        jPanel7 = new javax.swing.JPanel();
        chkEndUseCurPoint = new javax.swing.JCheckBox();
        jPnlCurrentParam = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLblCurrentParam = new javax.swing.JLabel();
        jScrollParams = new javax.swing.JScrollPane();
        jTableParams = new javax.swing.JTable();

        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(500, 400));
        setLayout(new java.awt.BorderLayout());

        jPnlChartTools.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
        jPnlChartTools.setName("jPnlChartTools"); // NOI18N
        jPnlChartTools.setPreferredSize(new java.awt.Dimension(150, 200));
        jPnlChartTools.setLayout(new java.awt.BorderLayout());

        jPanel9.setName("jPanel9"); // NOI18N

        txtTraceYCoord.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getResourceMap(JpnlFinalParams.class);
        txtTraceYCoord.setText(resourceMap.getString("txtTraceYCoord.text")); // NOI18N
        txtTraceYCoord.setToolTipText(resourceMap.getString("txtTraceYCoord.toolTipText")); // NOI18N
        txtTraceYCoord.setName("txtTraceYCoord"); // NOI18N

        jLblYCoord.setText(resourceMap.getString("jLblYCoord.text")); // NOI18N
        jLblYCoord.setName("jLblYCoord"); // NOI18N

        jLabel4.setFont(jLabel4.getFont().deriveFont(jLabel4.getFont().getStyle() | java.awt.Font.BOLD));
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLblXCoord.setText(resourceMap.getString("jLblXCoord.text")); // NOI18N
        jLblXCoord.setName("jLblXCoord"); // NOI18N

        txtTraceXCoord.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtTraceXCoord.setText(resourceMap.getString("txtTraceXCoord.text")); // NOI18N
        txtTraceXCoord.setToolTipText(resourceMap.getString("txtTraceXCoord.toolTipText")); // NOI18N
        txtTraceXCoord.setName("txtTraceXCoord"); // NOI18N

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLblYCoord)
                            .addComponent(jLblXCoord))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtTraceXCoord, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTraceYCoord, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGap(35, 35, 35)
                        .addComponent(jLabel4)))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        jPanel9Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {txtTraceXCoord, txtTraceYCoord});

        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, false)
                    .addComponent(txtTraceXCoord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLblXCoord))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, false)
                    .addComponent(txtTraceYCoord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLblYCoord))
                .addContainerGap())
        );

        jPnlChartTools.add(jPanel9, java.awt.BorderLayout.SOUTH);

        jPanel10.setName("jPanel10"); // NOI18N
        jPanel10.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 15));

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getActionMap(JpnlFinalParams.class, this);
        btnToggleDerivatives.setAction(actionMap.get("toggleDerivatives")); // NOI18N
        btnToggleDerivatives.setFont(btnToggleDerivatives.getFont().deriveFont(btnToggleDerivatives.getFont().getSize()-2f));
        btnToggleDerivatives.setIcon(resourceMap.getIcon("btnToggleDerivatives.icon")); // NOI18N
        btnToggleDerivatives.setText(resourceMap.getString("btnToggleDerivatives.text")); // NOI18N
        btnToggleDerivatives.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btnToggleDerivatives.setName("btnToggleDerivatives"); // NOI18N
        jPanel10.add(btnToggleDerivatives);

        btnConstantFifty.setAction(actionMap.get("toggleConstantValue")); // NOI18N
        btnConstantFifty.setFont(btnConstantFifty.getFont().deriveFont(btnConstantFifty.getFont().getSize()-2f));
        btnConstantFifty.setIcon(resourceMap.getIcon("btnConstantFifty.icon")); // NOI18N
        btnConstantFifty.setText(resourceMap.getString("btnConstantFifty.text")); // NOI18N
        btnConstantFifty.setName("btnConstantFifty"); // NOI18N
        jPanel10.add(btnConstantFifty);

        jPnlChartTools.add(jPanel10, java.awt.BorderLayout.CENTER);

        add(jPnlChartTools, java.awt.BorderLayout.LINE_END);

        jPnlPlot.setName("jPnlPlot"); // NOI18N
        jPnlPlot.setPreferredSize(new java.awt.Dimension(240, 200));
        jPnlPlot.setLayout(new java.awt.BorderLayout());

        jSliderPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jSliderPanel.setName("jSliderPanel"); // NOI18N
        jSliderPanel.setPreferredSize(new java.awt.Dimension(240, 45));
        jSliderPanel.setLayout(new java.awt.BorderLayout());

        jXYSlider.setName("jXYSlider"); // NOI18N
        jXYSlider.setPreferredSize(new java.awt.Dimension(204, 30));
        jSliderPanel.add(jXYSlider, java.awt.BorderLayout.CENTER);

        jPnlPlot.add(jSliderPanel, java.awt.BorderLayout.SOUTH);

        jPnlParamChart.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPnlParamChart.setName("jPnlParamChart"); // NOI18N
        jPnlParamChart.setLayout(new java.awt.BorderLayout());
        jPnlPlot.add(jPnlParamChart, java.awt.BorderLayout.CENTER);

        add(jPnlPlot, java.awt.BorderLayout.CENTER);

        jPnlResults.setName("jPnlResults"); // NOI18N
        jPnlResults.setPreferredSize(new java.awt.Dimension(400, 175));
        jPnlResults.setLayout(new java.awt.BorderLayout());

        jPnlParams.setName("jPnlParams"); // NOI18N
        jPnlParams.setPreferredSize(new java.awt.Dimension(330, 170));
        jPnlParams.setLayout(new java.awt.BorderLayout());

        jPnlEditParam.setName("jPnlEditParam"); // NOI18N
        jPnlEditParam.setPreferredSize(new java.awt.Dimension(300, 130));
        jPnlEditParam.setLayout(new java.awt.BorderLayout());

        jPnlBtnsParams.setName("jPnlBtnsParams"); // NOI18N
        jPnlBtnsParams.setPreferredSize(new java.awt.Dimension(300, 65));
        jPnlBtnsParams.setRequestFocusEnabled(false);
        jPnlBtnsParams.setLayout(new java.awt.GridLayout(2, 0));

        jPanel3.setName("jPanel3"); // NOI18N

        jLabel9.setFont(jLabel9.getFont().deriveFont(jLabel9.getFont().getStyle() & ~java.awt.Font.BOLD, jLabel9.getFont().getSize()-2));
        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N
        jPanel3.add(jLabel9);

        txtParamValue.setBackground(resourceMap.getColor("txtParamValue.background")); // NOI18N
        txtParamValue.setEditable(false);
        txtParamValue.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtParamValue.setName("txtParamValue"); // NOI18N
        txtParamValue.setPreferredSize(new java.awt.Dimension(75, 23));
        jPanel3.add(txtParamValue);

        jPnlBtnsParams.add(jPanel3);

        jPanel4.setName("jPanel4"); // NOI18N

        btnConfirm.setAction(actionMap.get("updateAnalysisParameter")); // NOI18N
        btnConfirm.setFont(btnConfirm.getFont().deriveFont(btnConfirm.getFont().getSize()-1f));
        btnConfirm.setIcon(resourceMap.getIcon("btnConfirm.icon")); // NOI18N
        btnConfirm.setText(resourceMap.getString("btnConfirm.text")); // NOI18N
        btnConfirm.setToolTipText(resourceMap.getString("btnConfirm.toolTipText")); // NOI18N
        btnConfirm.setName("btnConfirm"); // NOI18N
        btnConfirm.setPreferredSize(new java.awt.Dimension(95, 25));
        jPanel4.add(btnConfirm);

        btnReset.setAction(actionMap.get("restoreOriginalParameters")); // NOI18N
        btnReset.setFont(btnReset.getFont().deriveFont(btnReset.getFont().getSize()-1f));
        btnReset.setIcon(resourceMap.getIcon("btnReset.icon")); // NOI18N
        btnReset.setText(resourceMap.getString("btnReset.text")); // NOI18N
        btnReset.setToolTipText(resourceMap.getString("btnReset.toolTipText")); // NOI18N
        btnReset.setName("btnReset"); // NOI18N
        jPanel4.add(btnReset);

        jPnlBtnsParams.add(jPanel4);

        jPnlEditParam.add(jPnlBtnsParams, java.awt.BorderLayout.CENTER);

        jPnlParamsPoints.setName("jPnlParamsPoints"); // NOI18N
        jPnlParamsPoints.setPreferredSize(new java.awt.Dimension(300, 85));
        jPnlParamsPoints.setLayout(new java.awt.GridLayout(1, 0));

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Punto Inicial (P1)", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jPanel2.border.titleFont"))); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setLayout(new java.awt.GridLayout(2, 0));

        jPanel5.setName("jPanel5"); // NOI18N

        jLblP1X.setText(resourceMap.getString("jLblP1X.text")); // NOI18N
        jLblP1X.setName("jLblP1X"); // NOI18N
        jPanel5.add(jLblP1X);

        txtXStartPoint.setBackground(resourceMap.getColor("txtXStartPoint.background")); // NOI18N
        txtXStartPoint.setEditable(false);
        txtXStartPoint.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtXStartPoint.setText(resourceMap.getString("txtXStartPoint.text")); // NOI18N
        txtXStartPoint.setName("txtXStartPoint"); // NOI18N
        txtXStartPoint.setPreferredSize(new java.awt.Dimension(45, 23));
        jPanel5.add(txtXStartPoint);

        jLblP1Y.setText(resourceMap.getString("jLblP1Y.text")); // NOI18N
        jLblP1Y.setName("jLblP1Y"); // NOI18N
        jPanel5.add(jLblP1Y);

        txtYStartPoint.setBackground(resourceMap.getColor("txtYStartPoint.background")); // NOI18N
        txtYStartPoint.setEditable(false);
        txtYStartPoint.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtYStartPoint.setText(resourceMap.getString("txtYStartPoint.text")); // NOI18N
        txtYStartPoint.setName("txtYStartPoint"); // NOI18N
        txtYStartPoint.setPreferredSize(new java.awt.Dimension(45, 23));
        jPanel5.add(txtYStartPoint);

        jPanel2.add(jPanel5);

        jPanel6.setName("jPanel6"); // NOI18N

        chkStartUseCurPoint.setAction(actionMap.get("traceCurrentStartPoint")); // NOI18N
        chkStartUseCurPoint.setFont(chkStartUseCurPoint.getFont().deriveFont(chkStartUseCurPoint.getFont().getSize()-2f));
        chkStartUseCurPoint.setText(resourceMap.getString("chkStartUseCurPoint.text")); // NOI18N
        chkStartUseCurPoint.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        chkStartUseCurPoint.setName("chkStartUseCurPoint"); // NOI18N
        jPanel6.add(chkStartUseCurPoint);
        chkStartUseCurPoint.getAccessibleContext().setAccessibleName(resourceMap.getString("chkStartUseCurPoint.AccessibleContext.accessibleName")); // NOI18N

        jPanel2.add(jPanel6);

        jPnlParamsPoints.add(jPanel2);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), resourceMap.getString("jPanel1.border.title"), javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jPanel2.border.titleFont"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setPreferredSize(new java.awt.Dimension(180, 95));
        jPanel1.setLayout(new java.awt.GridLayout(2, 0));

        jPanel8.setName("jPanel8"); // NOI18N

        jLblp2X.setText(resourceMap.getString("jLblp2X.text")); // NOI18N
        jLblp2X.setName("jLblp2X"); // NOI18N
        jPanel8.add(jLblp2X);

        txtXEndPoint.setBackground(resourceMap.getColor("txtXEndPoint.background")); // NOI18N
        txtXEndPoint.setEditable(false);
        txtXEndPoint.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtXEndPoint.setText(resourceMap.getString("txtXEndPoint.text")); // NOI18N
        txtXEndPoint.setName("txtXEndPoint"); // NOI18N
        txtXEndPoint.setPreferredSize(new java.awt.Dimension(45, 23));
        jPanel8.add(txtXEndPoint);

        jLblP2Y.setText(resourceMap.getString("jLblP2Y.text")); // NOI18N
        jLblP2Y.setName("jLblP2Y"); // NOI18N
        jPanel8.add(jLblP2Y);

        txtYEndPoint.setBackground(resourceMap.getColor("txtYEndPoint.background")); // NOI18N
        txtYEndPoint.setEditable(false);
        txtYEndPoint.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtYEndPoint.setText(resourceMap.getString("txtYEndPoint.text")); // NOI18N
        txtYEndPoint.setName("txtYEndPoint"); // NOI18N
        txtYEndPoint.setPreferredSize(new java.awt.Dimension(45, 23));
        jPanel8.add(txtYEndPoint);

        jPanel1.add(jPanel8);

        jPanel7.setName("jPanel7"); // NOI18N

        chkEndUseCurPoint.setAction(actionMap.get("traceCurrentEndPoint")); // NOI18N
        chkEndUseCurPoint.setFont(chkEndUseCurPoint.getFont().deriveFont(chkEndUseCurPoint.getFont().getSize()-2f));
        chkEndUseCurPoint.setText(resourceMap.getString("chkEndUseCurPoint.text")); // NOI18N
        chkEndUseCurPoint.setName("chkEndUseCurPoint"); // NOI18N
        jPanel7.add(chkEndUseCurPoint);

        jPanel1.add(jPanel7);

        jPnlParamsPoints.add(jPanel1);

        jPnlEditParam.add(jPnlParamsPoints, java.awt.BorderLayout.PAGE_START);

        jPnlParams.add(jPnlEditParam, java.awt.BorderLayout.CENTER);

        jPnlCurrentParam.setName("jPnlCurrentParam"); // NOI18N
        jPnlCurrentParam.setPreferredSize(new java.awt.Dimension(191, 18));
        jPnlCurrentParam.setRequestFocusEnabled(false);
        jPnlCurrentParam.setLayout(new java.awt.BorderLayout());

        jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getStyle() | java.awt.Font.BOLD, jLabel1.getFont().getSize()-1));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        jLabel1.setPreferredSize(new java.awt.Dimension(80, 13));
        jPnlCurrentParam.add(jLabel1, java.awt.BorderLayout.LINE_START);

        jLblCurrentParam.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblCurrentParam.setText(resourceMap.getString("jLblCurrentParam.text")); // NOI18N
        jLblCurrentParam.setName("jLblCurrentParam"); // NOI18N
        jPnlCurrentParam.add(jLblCurrentParam, java.awt.BorderLayout.CENTER);

        jPnlParams.add(jPnlCurrentParam, java.awt.BorderLayout.PAGE_START);

        jPnlResults.add(jPnlParams, java.awt.BorderLayout.EAST);

        jScrollParams.setName("jScrollParams"); // NOI18N
        jScrollParams.setPreferredSize(new java.awt.Dimension(190, 170));
        jScrollParams.setRequestFocusEnabled(false);

        jTableParams.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jTableParams.setName("jTableParams"); // NOI18N
        jTableParams.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollParams.setViewportView(jTableParams);

        jPnlResults.add(jScrollParams, java.awt.BorderLayout.CENTER);

        add(jPnlResults, java.awt.BorderLayout.SOUTH);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnConfirm;
    private javax.swing.JButton btnConstantFifty;
    private javax.swing.JButton btnReset;
    private javax.swing.JButton btnToggleDerivatives;
    private javax.swing.JCheckBox chkEndUseCurPoint;
    private javax.swing.JCheckBox chkStartUseCurPoint;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLblCurrentParam;
    private javax.swing.JLabel jLblP1X;
    private javax.swing.JLabel jLblP1Y;
    private javax.swing.JLabel jLblP2Y;
    private javax.swing.JLabel jLblXCoord;
    private javax.swing.JLabel jLblYCoord;
    private javax.swing.JLabel jLblp2X;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JPanel jPnlBtnsParams;
    private javax.swing.JPanel jPnlChartTools;
    private javax.swing.JPanel jPnlCurrentParam;
    private javax.swing.JPanel jPnlEditParam;
    private javax.swing.JPanel jPnlParamChart;
    private javax.swing.JPanel jPnlParams;
    private javax.swing.JPanel jPnlParamsPoints;
    private javax.swing.JPanel jPnlPlot;
    private javax.swing.JPanel jPnlResults;
    private javax.swing.JScrollPane jScrollParams;
    private javax.swing.JPanel jSliderPanel;
    private javax.swing.JTable jTableParams;
    private javax.swing.JSlider jXYSlider;
    private javax.swing.JTextField txtParamValue;
    private javax.swing.JTextField txtTraceXCoord;
    private javax.swing.JTextField txtTraceYCoord;
    private javax.swing.JTextField txtXEndPoint;
    private javax.swing.JTextField txtXStartPoint;
    private javax.swing.JTextField txtYEndPoint;
    private javax.swing.JTextField txtYStartPoint;
    // End of variables declaration//GEN-END:variables
}
